# -*- coding: utf-8 -*-

import os
import sys
import threading
from uart import Uart
from time import sleep

class Tool(object):
    def __init__(self , parent):
        self.err = 0
        self.parent = parent
        #print("tool called")
        print(self.parent.baud_rate)
        self.uart = Uart(self ,self.parent.uart_port , self.parent.baud_rate)

    def open_selial(self):
        self.uart.open_port_opr()
        #启用测试接收线程
    #    self.start_listen_uart()

    #监听串口接收端口线程
    def start_listen_uart(self):
        threading.Thread(target=self.listen_uart_data_thread,daemon=True).start()

    #监听函数
    def listen_uart_data_thread(self):
        print("listen_uart_data_thread started")
        while(True):
            print("listending...")
            sleep(3)
    #回调函数
    def data_rcv_back_call(self,data):
        self.parent.signal_recv_data.emit(data)
        #self.parent.testBrowser_show_data(data)


